package algocasts;

public class P31_maxWater {
    public int maxWater(int[] height) {
        int max = 0;
        int left = 0, right = height.length - 1;
        while (left < right) {
            int cur = Math.min(height[left], height[right]) * (right - left);
            max = Math.max(cur, max);
            // 哪边低移动哪边
            if (height[left] < height[right]) left++;
            else right--;
        }
        return max;
    }
}
